package com.is2.patchinglife.manager;

import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;

public class ContentManager {
	public static final String countSMS = "countSMS_01";
	public static final String countContacts = "countContacts_01";
	
	//Destinazioni query
	public static final Uri contact_content = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; //rubrica
	public static final Uri sms_content = Uri.parse("content://sms"); //sms
	
	private ContentManager(){}
	
	/** Counts the number of contacts on device **/
	public static int countContacts(){
		Cursor cursor = LocalDataManager.getFileManager().getContext()
						.getContentResolver().query(contact_content, null, null, null, null);
		int num_contacts = cursor.getCount();
		return num_contacts;
	}
	
	/** Verify "count number of contacts" trophy **/
	public static boolean trophyCountContacts(int num){
		if(num<=countContacts()){
			LocalDataManager.gotNewTrophy(countContacts);
			NotificationHandler.displayNotificationMessage(LocalDataManager.getName(countContacts),LocalDataManager.getDesc(countContacts),LocalDataManager.getID(countContacts));
			return true;
		}else{
			return false;
		}
		
	}
	
	/** Counts the number of SMS on device **/
	public static int countSMS(){
		Cursor cursor = LocalDataManager.getFileManager().getContext()
						.getContentResolver().query(sms_content, null, null, null, null);
		int num_sms = cursor.getCount();
		return num_sms;
	}
	
	/** Verify "count number of SMS" trophy **/
	public static boolean trophyCountSMS(int num){
		if(num<=countSMS()){
			LocalDataManager.gotNewTrophy(countSMS);
			NotificationHandler.displayNotificationMessage(LocalDataManager.getName(countSMS),LocalDataManager.getDesc(countSMS),LocalDataManager.getID(countSMS));
			return true;
		}else{
			return false;
		}
	}

}
